package realQuestion.ali;

import java.util.*;

public class Solution{
    public  List<List<String>>  classify(String[] strings){
        Map<String,List<String>> map=new HashMap<>();
        for(String str:strings){
            char[]  chars=str.toCharArray();
            Arrays.sort(chars);
            String sortedStr=new String(chars);
            if(!map.containsKey(sortedStr)){
                map.put(sortedStr,new ArrayList<>());
            }
            map.get(sortedStr).add(str);
        }
        return new ArrayList<>(map.values());
    }

    public  static void main(String[] args){
        Solution  solution=  new  Solution();
        String[] strings={"eat", "tea", "tan", "ate", "nat", "bat"};
        List<List<String>> classify = solution.classify(strings);
        for (List<String> a: classify
             ) {
            System.out.println(a);

        }

    }
}
